﻿using System.Reflection;
using WindowsGame.Common;
using WindowsGame.Common.Static;
using NUnit.Framework;

namespace WindowsGame.SystemTests.Managers
{
	[TestFixture]
	public class ConfigManagerTests : BaseSystemTests
	{
#pragma warning disable 618
		[TestFixtureSetUp]
#pragma warning restore 618
		public new void TestFixtureSetUp()
		{
			// System under test.
			ConfigManager = MyGame.Manager.ConfigManager;
			ConfigManager.Initialize(CONTENT_ROOT);
		}

		[Test]
		public void LoadBoardDataTest()
		{
			ConfigManager.LoadBoardData();
			var boardType = ConfigManager.BoardType;
			Assert.That(boardType, Is.EqualTo(BoardType.Small));
		}

		[Test]
		public void LoadConfigDataTest()
		{
			ConfigManager.LoadConfigData();
			var configData = ConfigManager.ConfigData;
			Assert.That(configData, Is.Not.Null);

			var fields = configData.GetType().GetFields();
			foreach (FieldInfo field in fields)
			{
				object obj = field.GetValue(configData);
				Assert.That(obj, Is.Not.Null, field.ToString());
			}
		}

		[Test]
		public void LoadSnakeDataTest()
		{
			ConfigManager.LoadSnakeData();
			var snakeData = ConfigManager.SnakeData;
			Assert.That(8, Is.EqualTo(snakeData.Length));
		}

	}
}